package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TYearEffectInfoTemp;
import cn.com.headfree.mouldshow.dao.TYearEffectInfoTempDao;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Repository("/tYearEffectInfoTempDao")
public class TYearEffectInfoTempDaoImpl extends BaseDaoImpl<TYearEffectInfoTemp> implements TYearEffectInfoTempDao {


    @Override
    public void saveInfo(TYearEffectInfoTemp yearEffectInfo) {
        String sql = "insert into t_year_effect_info_temp (id,erp_no,user_name,id_card_no,rate_year_start,rate_year_end,rate_year,perfor_grade,resi_inte,cur_inte,org_id,creater_id,creater_name,create_time,updater_id,updater_name,update_time,del_sign,is_valid,audit_state,orignal_id,business_type_id,primitive_id) values ";
        StringBuilder sqlBuilder = new StringBuilder(sql);
        sqlBuilder.append("(#{id,jdbcType=VARCHAR},").append("#{erp_no,jdbcType=VARCHAR},").append("#{user_name,jdbcType=VARCHAR},")
                .append("#{id_card_no,jdbcType=VARCHAR},").append("#{rate_year_start,jdbcType=DATE},")
                .append("#{rate_year_end,jdbcType=DATE},").append("#{rate_year,jdbcType=INTEGER},").append("#{perfor_grade,jdbcType=VARCHAR},")
                .append("#{resi_inte,jdbcType=DOUBLE},").append("#{cur_inte,jdbcType=DOUBLE},")
                .append("#{org_id,jdbcType=VARCHAR},").append("#{creater_id,jdbcType=VARCHAR},")
                .append("#{creater_name,jdbcType=DATE},").append("#{create_time,jdbcType=DATE},")
                .append("#{updater_id,jdbcType=VARCHAR},").append("#{updater_name,jdbcType=VARCHAR},")
                .append("#{update_time,jdbcType=DATE},").append("#{del_sign,jdbcType=INTEGER},")
                .append("#{is_valid,jdbcType=INTEGER},").append("#{audit_state,jdbcType=INTEGER},")
                .append("#{orignal_id,jdbcType=VARCHAR},").append("#{business_type_id,jdbcType=VARCHAR},")
                .append("#{primitive_id,jdbcType=VARCHAR})");
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", yearEffectInfo.getId());
        params.put("erp_no", yearEffectInfo.getErpNo());
        params.put("user_name", yearEffectInfo.getUserName());
        params.put("id_card_no", yearEffectInfo.getIdCardNo());
        params.put("rate_year_start", yearEffectInfo.getRateYearStart());
        params.put("rate_year_end", yearEffectInfo.getRateYearEnd());
        params.put("rate_year", yearEffectInfo.getRateYear());
        params.put("perfor_grade", yearEffectInfo.getPerforGrade());
        params.put("resi_inte", yearEffectInfo.getResiInte());
        params.put("cur_inte", yearEffectInfo.getCurInte());
        params.put("org_id", yearEffectInfo.getOrgId());
        params.put("creater_id", yearEffectInfo.getCreaterId());
        params.put("creater_name", yearEffectInfo.getCreaterName());
        params.put("create_time", new Timestamp(new Date().getTime()));
        params.put("updater_id", yearEffectInfo.getUpdaterId());
        params.put("updater_name", yearEffectInfo.getUpdaterName());
        params.put("update_time", new Timestamp(new Date().getTime()));
        params.put("del_sign", 0);
        params.put("is_valid", yearEffectInfo.getIsValid());
        params.put("audit_state", yearEffectInfo.getAuditState());
        params.put("orignal_id", yearEffectInfo.getOrignalId());
        params.put("business_type_id", yearEffectInfo.getBusinessTypeId());
        params.put("primitive_id", yearEffectInfo.getPrimitiveId());
        this.executeSql(sqlBuilder.toString(), params);
    }
}
